var login = {
	init : function(){
		login.initLoginId();
		$("#userId").focus();
		return true;
	},

	formChk: function (){
		if(!$("form#adminLoginModel").validation()) return false;

		if($("#chkLoginIdSave").prop("checked")){
			login.setCookie("sr_login_id", $("#id").val(), 365);
		}
		else{
			login.setCookie("sr_login_id", $("#id").val(), -1);
		}
		return true;
	},

	initLoginId: function (){
		var cookieLoginId = login.getCookie("sr_login_id");
		if(cookieLoginId != ""){
			$("#chkLoginIdSave").prop("checked", true);
			$("#id").val(cookieLoginId);
		}
	},

	setCookie: function (name, value, expiredays){
		var today = new Date();
		today.setDate( today.getDate() + expiredays );
		document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + today.toGMTString() + ";";
	},

	getCookie: function (name){
		var cook = document.cookie + ";";
		var idx = cook.indexOf(name, 0);
		var val = "";

		if(idx != -1){
			cook = cook.substring(idx, cook.length);
			var begin = cook.indexOf("=", 0) + 1;
			var end = cook.indexOf(";", begin);
			val = unescape( cook.substring(begin, end) );
		}
		return val;
	}
};

$(function(){
	login.init();
});